using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

using TrueCode.Core.Aspects;

namespace EMan.Common.EnterpriseStructure
{
  [DataContract]
  public class StructureChangeset
  {
    [DataMember]
    private readonly IEnumerable< Department > _newDepartments;

    [DataMember]
    private readonly IEnumerable< Department > _modifiedDepartments;

    [DataMember]
    private readonly IEnumerable< int > _deletedDepartments;

    [DataMember]
    private IEnumerable< Employee > _newEmployees;

    [DataMember]
    private IEnumerable< Employee > _modifiedEmployees;

    [DataMember]
    private IEnumerable< int > _deletedEmployees;

    public StructureChangeset( [NotNull] IEnumerable< Department > newDepartments,
                               [NotNull] IEnumerable< Department > modifiedDepartments,
                               [NotNull] IEnumerable< int > deletedDepartments,
                               [NotNull] IEnumerable< Employee > newEmployees,
                               [NotNull] IEnumerable< Employee > modifiedEmployees,
                               [NotNull] IEnumerable< int > deletedEmployees )
    {
      #region Validation
      if( newDepartments == null ) throw new ArgumentNullException( "newDepartments" );
      if( modifiedDepartments == null ) throw new ArgumentNullException( "modifiedDepartments" );
      if( deletedDepartments == null ) throw new ArgumentNullException( "deletedDepartments" );
      if( newEmployees == null ) throw new ArgumentNullException( "newEmployees" );
      if( modifiedEmployees == null ) throw new ArgumentNullException( "modifiedEmployees" );
      if( deletedEmployees == null ) throw new ArgumentNullException( "deletedEmployees" );
      #endregion

      _newDepartments = newDepartments;
      _modifiedDepartments = modifiedDepartments;
      _deletedDepartments = deletedDepartments;
      _newEmployees = newEmployees;
      _modifiedEmployees = modifiedEmployees;
      _deletedEmployees = deletedEmployees;
    }


    public IEnumerable< Department > NewDepartments
    {
      get { return _newDepartments; }
    }

    public IEnumerable< Department > ModifiedDepartments
    {
      get { return _modifiedDepartments; }
    }
    
    public IEnumerable< int > DeletedDepartments
    {
      get { return _deletedDepartments; }
    }

    public IEnumerable< Employee > NewEmployees
    {
      get { return _newEmployees; }
    }

    public IEnumerable< Employee > ModifiedEmployees
    {
      get { return _modifiedEmployees; }
    }

    public IEnumerable< int > DeletedEmployees
    {
      get { return _deletedEmployees; }
    }
  }
}